<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Bomberman:  Fichier source de /home/ph3w/Bureau/lif7-bomberman/QList.inl</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Généré par Doxygen 1.7.1 -->
<script type="text/javascript">
function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}

function toggleVisibility(linkObj) {
 var base = linkObj.getAttribute('id');
 var summary = document.getElementById(base + '-summary');
 var content = document.getElementById(base + '-content');
 var trigger = document.getElementById(base + '-trigger');
 if ( hasClass(linkObj,'closed') ) {
   summary.style.display = 'none';
   content.style.display = 'block';
   trigger.src = 'open.png';
   removeClass(linkObj,'closed');
   addClass(linkObj,'opened');
 } else if ( hasClass(linkObj,'opened') ) {
   summary.style.display = 'block';
   content.style.display = 'none';
   trigger.src = 'closed.png';
   removeClass(linkObj,'opened');
   addClass(linkObj,'closed');
 }
 return false;
}
</script>
<div class="header">
  <div class="headertitle">
<h1>/home/ph3w/Bureau/lif7-bomberman/QList.inl</h1>  </div>
</div>
<div class="contents">
<a href="_q_list_8inl.html">Aller à la documentation de ce fichier.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00002"></a><a class="code" href="class_q_list.html#a1ba2656b5fa0790c29790373e9fee411">00002</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_q_list.html#a1ba2656b5fa0790c29790373e9fee411">QList&lt;Type&gt;::size</a>()
<a name="l00003"></a>00003 {
<a name="l00004"></a>00004     <span class="keywordflow">return</span> <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>;
<a name="l00005"></a>00005 }
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00009"></a><a class="code" href="class_q_list.html#ab3d7f4bbc5c4b7ee887d95e1739c8354">00009</a> <span class="keyword">inline</span> Type&amp; <a class="code" href="class_q_list.html#ab3d7f4bbc5c4b7ee887d95e1739c8354">QList&lt;Type&gt;::operator[]</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n)
<a name="l00010"></a>00010 {
<a name="l00011"></a>00011     <span class="keywordflow">return</span> <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[n];
<a name="l00012"></a>00012 }
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00016"></a><a class="code" href="class_q_list.html#ae084fb8abf05b0564d11ad0b92d955d5">00016</a> <a class="code" href="class_q_list.html#ae084fb8abf05b0564d11ad0b92d955d5">QList&lt;Type&gt;::QList</a>()
<a name="l00017"></a>00017 {
<a name="l00018"></a>00018     <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> = 0;
<a name="l00019"></a>00019     <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a> = 0;
<a name="l00020"></a>00020 }
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00024"></a><a class="code" href="class_q_list.html#a8085cc58373d76dce47a058338f3e0f5">00024</a> <a class="code" href="class_q_list.html#ae084fb8abf05b0564d11ad0b92d955d5">QList&lt;Type&gt;::QList</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nb, Type&amp; fill )
<a name="l00025"></a>00025 {
<a name="l00026"></a>00026     <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a> = nb;
<a name="l00027"></a>00027     <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> = <span class="keyword">new</span> Type[nb];
<a name="l00028"></a>00028     <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;nb; i++ )
<a name="l00029"></a>00029         <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[i] = fill;
<a name="l00030"></a>00030 }
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00034"></a><a class="code" href="class_q_list.html#a70fb8092458488b844bc60d3a900bcde">00034</a> <a class="code" href="class_q_list.html#a70fb8092458488b844bc60d3a900bcde">QList&lt;Type&gt;::~QList</a>()
<a name="l00035"></a>00035 {
<a name="l00036"></a>00036     <span class="keywordflow">if</span>( <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> &amp;&amp; <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a> )
<a name="l00037"></a>00037         <span class="keyword">delete</span>[] <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>;
<a name="l00038"></a>00038 
<a name="l00039"></a>00039     <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> = 0;
<a name="l00040"></a>00040     <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a> = 0;
<a name="l00041"></a>00041 }
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00045"></a><a class="code" href="class_q_list.html#a6e17a1550e8b90dd62b1df93be56d995">00045</a> <span class="keywordtype">void</span> <a class="code" href="class_q_list.html#a6e17a1550e8b90dd62b1df93be56d995">QList&lt;Type&gt;::resize</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size, Type&amp; fill )
<a name="l00046"></a>00046 {
<a name="l00047"></a>00047     <span class="keywordflow">if</span>( <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> )
<a name="l00048"></a>00048         <span class="keyword">delete</span>[] <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>;
<a name="l00049"></a>00049 
<a name="l00050"></a>00050     <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a> = size;
<a name="l00051"></a>00051     <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> = <span class="keyword">new</span> Type[size];
<a name="l00052"></a>00052     <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;size; i++ )
<a name="l00053"></a>00053         <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[i] = fill;
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00058"></a><a class="code" href="class_q_list.html#a250d44beb2d93d79cb9543ed6988f72f">00058</a> Type&amp; <a class="code" href="class_q_list.html#a250d44beb2d93d79cb9543ed6988f72f">QList&lt;Type&gt;::at</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n)
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060     <span class="keywordflow">if</span>( n &gt;= <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a> )
<a name="l00061"></a>00061         stdErrorE(<span class="stringliteral">&quot;Tentative d&#39;accès a une case mémoire non existante ! Cases mémoires disponible [0-%u[ et demande d&#39;accès à %u&quot;</span>, <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>, n);
<a name="l00062"></a>00062 
<a name="l00063"></a>00063     <span class="keywordflow">return</span> <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[n];
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065 
<a name="l00066"></a>00066 
<a name="l00067"></a>00067 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00068"></a><a class="code" href="class_q_list.html#a15e8824a8dd6a49fda33581299c3bf77">00068</a> <span class="keywordtype">void</span> <a class="code" href="class_q_list.html#a15e8824a8dd6a49fda33581299c3bf77">QList&lt;Type&gt;::operator&lt;&lt;</a>( <span class="keyword">const</span> Type&amp; newObj )
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070     <span class="keywordflow">if</span>( <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> ){
<a name="l00071"></a>00071         Type* tmp = <span class="keyword">new</span> Type[<a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>+1];
<a name="l00072"></a>00072         <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>; i++ )
<a name="l00073"></a>00073             tmp[i] = <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[i];
<a name="l00074"></a>00074 
<a name="l00075"></a>00075         <span class="keyword">delete</span>[] <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>;
<a name="l00076"></a>00076         <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> = tmp;
<a name="l00077"></a>00077         <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[c_nb_ojb] = newObj;
<a name="l00078"></a>00078         c_nb_ojb++;
<a name="l00079"></a>00079 
<a name="l00080"></a>00080     }<span class="keywordflow">else</span>{
<a name="l00081"></a>00081         <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> = <span class="keyword">new</span> Type[1];
<a name="l00082"></a>00082         <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[0] = newObj;
<a name="l00083"></a>00083         <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a> = 1;
<a name="l00084"></a>00084     }
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00089"></a><a class="code" href="class_q_list.html#a8c2b248e4501a99eb71c2fe84f1caf79">00089</a> <span class="keywordtype">void</span> <a class="code" href="class_q_list.html#a8c2b248e4501a99eb71c2fe84f1caf79">QList&lt;Type&gt;::insert</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> at, <span class="keyword">const</span> Type&amp; newObj )
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091     <span class="keywordflow">if</span>( at &gt;= <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a> ){
<a name="l00092"></a>00092         stdError(<span class="stringliteral">&quot;Attention ! insert impossible ! Insert à %u et case disponible [0-%u[&quot;</span>, at, <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>);
<a name="l00093"></a>00093         this-&gt;<a class="code" href="class_q_list.html#a15e8824a8dd6a49fda33581299c3bf77">operator &lt;&lt;</a>(newObj);
<a name="l00094"></a>00094         return ;
<a name="l00095"></a>00095     }
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 
<a name="l00098"></a>00098     Type* tmp = <span class="keyword">new</span> Type[<a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>+1];
<a name="l00099"></a>00099     <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;at; i++ )
<a name="l00100"></a>00100         tmp[i] = <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[i];
<a name="l00101"></a>00101 
<a name="l00102"></a>00102     tmp[at] = newObj;
<a name="l00103"></a>00103 
<a name="l00104"></a>00104     <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=at; i&lt;<a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>; i++ )
<a name="l00105"></a>00105         tmp[i+1] = <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[i];
<a name="l00106"></a>00106 
<a name="l00107"></a>00107     <span class="keyword">delete</span>[] <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>;
<a name="l00108"></a>00108     <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> = tmp;
<a name="l00109"></a>00109     c_nb_ojb++;
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111 
<a name="l00112"></a>00112 
<a name="l00113"></a>00113 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Type&gt;
<a name="l00114"></a><a class="code" href="class_q_list.html#a87d4d2405fe9f067a948d3edc24da1a0">00114</a> <span class="keywordtype">void</span> <a class="code" href="class_q_list.html#a87d4d2405fe9f067a948d3edc24da1a0">QList&lt;Type&gt;::remove</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> at )
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116     <span class="keywordflow">if</span>( at &gt;= <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a> )
<a name="l00117"></a>00117         stdErrorE(<span class="stringliteral">&quot;Attention ! remove impossible ! Remove à %u et case disponible [0-%u[&quot;</span>, at, <a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>);
<a name="l00118"></a>00118 
<a name="l00119"></a>00119     Type* tmp = <span class="keyword">new</span> Type[<a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>-1];
<a name="l00120"></a>00120     <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;at; i++ )
<a name="l00121"></a>00121         tmp[i] = <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[i];
<a name="l00122"></a>00122 
<a name="l00123"></a>00123     <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=at+1; i&lt;<a class="code" href="class_q_list.html#af436b7d8093a0130b0986b8152c32453">c_nb_ojb</a>; i++ )
<a name="l00124"></a>00124         tmp[i-1] = <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>[i];
<a name="l00125"></a>00125 
<a name="l00126"></a>00126     <span class="keyword">delete</span>[] <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a>;
<a name="l00127"></a>00127     <a class="code" href="class_q_list.html#a8419a0f68013a7657b1993ac44f79b07">c_list</a> = tmp;
<a name="l00128"></a>00128     c_nb_ojb--;
<a name="l00129"></a>00129 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Généré le Fri Jan 21 2011 01:21:27 pour Bomberman par&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
